package com.controller.admin.company;

import com.dao.AdminDao;
import com.dao.CompanyDao;
import com.dao.imp.AdminDaoimpl;
import com.dao.imp.CompanyDaoimpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/RemoveCompany")
public class RemoveCompanyServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");

        String companyId = req.getParameter("companyId");
        System.out.println("companyId = " + companyId);

        AdminDao AdminDao = new AdminDaoimpl();
        int i = AdminDao.delCompany(companyId);
        System.out.println("i = " + i);
        if(i==1){
            resp.getWriter().write("success");
        }else{
            resp.getWriter().write("fail");
        }

    }
}
